package com.slw.caiji.controller;


import com.slw.caiji.Vo.params.PageParams;
import com.slw.caiji.dto.SysRole;
import com.slw.caiji.dto.SysUser;
import com.slw.caiji.service.SysRoleService;
import com.slw.caiji.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/role")
@Api(tags = "角色管理")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @PostMapping("list")
    @Operation(summary = "分页获取角色列表", description = "分页获取角色列表")
    public Result getList(@RequestBody PageParams pageParams) {
        return sysRoleService.getSysRoleList(pageParams);
    }

    @PostMapping("add")
    @Operation(summary = "新增角色", description = "新增角色")
    public Result addUser(@RequestBody SysRole sysRole) {
        return sysRoleService.addRole(sysRole);
    }

    @GetMapping("del")
    @Operation(summary = "删除角色", description = "删除角色")
    public Result delUser(@RequestParam String ids) {
        return sysRoleService.delRole(ids);
    }

    @GetMapping("detail")
    @Operation(summary = "角色详情接口", description = "获取角色详情")
    public Result detailUser(@RequestParam String id) {
        return sysRoleService.detailRole(id);
    }

    @PostMapping("update")
    @Operation(summary = "更新角色接口", description = "编辑角色信息")
    public Result updateUser(@RequestBody SysRole sysRole) {
        return sysRoleService.updateRole(sysRole);
    }
}
